/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufscar.compiladores.ast;

import java.util.ArrayList;
import java.util.Collection;

/**
 *
 * @author takeshi
 */
public class VarDecList {

    private Collection<Variable> varDecList;

    public VarDecList(Collection<Variable> varDecList) {
        this.varDecList = varDecList;
    }

    public VarDecList() {
        this.varDecList = new ArrayList<Variable>();
    }

    public void genC(PW pw) {
        pw.print(varDecList.iterator().next().getType().getCname());
        
        int size = varDecList.size();
        for (Variable variable : varDecList){
            pw.out.print(" " + variable.getName());
            if (--size > 0) {
                pw.out.print(", ");
            }
        }
        pw.out.println(";");
    }

    public void add(Variable v) {
        varDecList.add(v);
    }

    @Override
    public String toString() {
        return varDecList.toString();
    }
    
}
